#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
	int N;

	bool isprim[33000];
	memset(isprim, 1, 33000);
	int temq = (int)sqrt((double)(33000));

	for (int i = 2; i <= temq; i++)
	{
		if (isprim[i] == false)
			continue;

		for (int j = i * i; j < 33000; j += i)
		{
			isprim[j] = false;
		}
	}

	isprim[0] = isprim[1] = isprim[2] = false;
	// for(int i = 3; i < 33; i++)
	//{
	//	if(isprim[i] == true)
	//	{
	//		cout<<i<<endl;
	//	}
	// }

	while (cin >> N)
	{
		if (N == 0)
			break;

		int hN = N / 2;

		int total = 0;
		for (int i = 3; i <= hN; i++)
		{
			if (isprim[i] == true)
			{
				if (isprim[N - i] == true)
				{
					total++;
				}
			}
		}

		cout << total << endl;
	}

	return 0;
}